macos: ensure GdkMacosWindow in surface discovery
authorChristian Hergert <chergert@redhat.com>
Thu, 31 Dec 2020 18:44:19 +0000 (10:44 -0800)
committerChristian Hergert <chergert@redhat.com>
Thu, 31 Dec 2020 18:55:50 +0000 (10:55 -0800)
We want to ignore windows that are not related to those controlled
by the GDK backend.

Fixes #3533

gdk/macos/gdkmacosdisplay-translate.c

index 5f5eeffdcfb3afc1cf2dc524cc19780299a4e2e8..b638b87ab9da0012452164505bac3a1c71c6656b 100644 (file)
@@ -762,7 +762,7 @@ get_surface_from_ns_event (GdkMacosDisplay *self,
   GdkSurface *surface = NULL;
   NSWindow *nswindow = [nsevent window];
 
-  if (nswindow)
+  if (GDK_IS_MACOS_WINDOW (nswindow))
     {
       GdkMacosBaseView *view;
       NSPoint point, view_point;
@@ -974,11 +974,11 @@ find_surface_for_ns_event (GdkMacosDisplay *self,
   g_assert (x != NULL);
   g_assert (y != NULL);
 
-  view = (GdkMacosBaseView *)[[nsevent window] contentView];
-
   if (!(surface = get_surface_from_ns_event (self, nsevent, &point, x, y)))
     return NULL;
 
+  view = (GdkMacosBaseView *)[GDK_MACOS_SURFACE (surface)->window contentView];
+
   _gdk_macos_display_from_display_coords (self, point.x, point.y, &x_tmp, &y_tmp);
 
   switch ((int)[nsevent type])